<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('抽奖列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>奖品名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>奖品等级：</label>
                                <select name="rewardlevel" th:with="type=${@dict.getType('choujiang_level')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>谣言：</label>
                                <input type="text" name="notice"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:choujiangset:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:choujiangset:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-success" onclick="openChouJiangInfo()" shiro:hasPermission="system:choujiangset:add">
                    <i class="fa fa-plus"></i>奖品概率配置
                </a>
                <a class="btn btn-warning refreshCache"  cus-type="refreshChouJiangInfo" shiro:hasPermission="system:fightdropset:refreshCache">
                    <i class="fa fa-download"></i> 刷新缓存
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:choujiangset:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:choujiangset:remove')}]];
        var rewardlevelDatas = [[${@dict.getType('choujiang_level')}]];
        var prefix = ctx + "system/choujiangset";
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "抽奖",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id', 
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'name', 
                    title: '奖品名称'
                },
                {
                    field: 'remark', 
                    title: '奖品'
                },
                {
                    field: 'rewardlevel', 
                    title: '奖品等级',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(rewardlevelDatas, value);
                    }
                },
                {
                    field: 'notice', 
                    title: '谣言'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
<script>
    function openChouJiangInfo(title, url, width, height, callback){
        //var ctx = window.location.host;
        sessionStorage.setItem('keyName',"choujiang")
        var url = "cache/queryCache";
        if ($.common.isMobile()) {
            width = 'auto';
            height = 'auto';
        }
        if ($.common.isEmpty(title)) {
            title = false;
        }
        if ($.common.isEmpty(url)) {
            url = "/404.html";
        }
        if ($.common.isEmpty(width)) {
            width = 800;
        }
        if ($.common.isEmpty(height)) {
            height = ($(window).height() - 50);
        }
        if ($.common.isEmpty(callback)) {
            callback = function(index, layero) {
                var iframeWin = layero.find('iframe')[0];
                iframeWin.contentWindow.submitHandler(index, layero);
            }
        }
        layer.open({
            type: 2,
            area: [width + 'px', height + 'px'],
            fix: false,
            //不固定
            maxmin: true,
            shade: 0.3,
            title: "修改积分抽奖信息",
            content: url,
            btn: [ '关闭','确定'],
            // 弹层外区域关闭
            shadeClose: true,
            yes: callback,
            cancel: function(index) {
                return true;
            }
        });

    }

</script>
</html>